package edu.umn.contactviewer.models;

import java.io.Serializable;

/**
 * Model class for storing a single contact.
 * 
 * 
 */

public class Contact implements Serializable, Comparable {
	/**
	 * 
	 */

	private static final long serialVersionUID = 1L;

	public Contact() {
		_id = "";
		name = "";
		phone = "";
		email = "";
		title = "";
		twitterId = "";
	}

	/**
	 * Creates a contact and assigns its name.
	 * 
	 * 
	 * 
	 * @param name
	 *            the contact's name
	 */

	public Contact(String name) {
		this.name = name;
		this.phone = "";
		this.email = "";
		this.title = "";
		this.twitterId = "";
	}

	private String _id;

	public void set_id(String _id) {
		this._id = _id;
	}

	public String get_id() {
		return _id;
	}

	private String name;

	/**
	 * Set the contact's name.
	 */

	public Contact setName(String name) {
		this.name = name;
		return this;
	}

	/**
	 * Get the contact's name.
	 */

	public String getName() {
		return this.name;
	}

	private String phone;

	/**
	 * 
	 * @return the contact's phone number
	 */

	public String getPhone() {
		return this.phone;
	}

	/**
	 * Set's the contact's phone number.
	 */

	public Contact setPhone(String phone) {
		this.phone = phone;
		return this;

	}

	private String title;

	/**
	 * 
	 * @return The contact's title
	 */

	public String getTitle() {
		return this.title;
	}

	/**
	 * Sets the contact's title.
	 */

	public Contact setTitle(String title) {
		this.title = title;
		return this;
	}

	private String email;

	/**
	 * 
	 * @return the contact's e-mail address
	 */

	public String getEmail() {
		return this.email;
	}

	/**
	 * Sets the contact's e-mail address.
	 */

	public Contact setEmail(String email) {
		this.email = email;
		return this;
	}

	private String twitterId;

	/**
	 * 
	 * @return the contact's Twitter ID
	 */

	public String getTwitterId() {
		return this.twitterId;
	}

	/**
	 * Sets the contact's Twitter ID.
	 */

	public Contact setTwitterId(String twitterId) {
		this.twitterId = twitterId;
		return this;
	}

	public String toString() {
		return this.name + " (" + this.title + ")";
	}

	public int compareTo(Object o) {
		Contact otherContact = (Contact) o;
		return this.name.compareTo(otherContact.getName());
	}
}